﻿using System;
using System.Globalization;
using System.Windows;
using System.Windows.Data;

namespace hStatsC.Converters
{
    public class BoolToVisibilityConverter : IValueConverter
    {
        public object Convert(object value, Type targetType, object parameter, CultureInfo culture)
        {
            bool? reverse = false;
            if (parameter != null)
            {
                reverse = parameter as bool?;
            }

            if (value == null)
            {
                return Visibility.Visible;
            }
            else
            {
                if ((bool)value)
                {
                    return  (reverse==false)?Visibility.Visible:Visibility.Hidden;
                }
                else
                {
                    return (reverse == false) ? Visibility.Hidden:Visibility.Visible;
                }
            }
        }

        public object ConvertBack(object value, Type targetType, object parameter, CultureInfo culture)
        {
            //throw new NotImplementedException();
            return null;
        }
    }
    public class NotNullToVisibilityConverter : IValueConverter
    {
        public object Convert(object value, Type targetType, object parameter, CultureInfo culture)
        {
            bool? reverse = false;
            if (parameter != null)
            {
                reverse = parameter as bool?;
            }

            if (value == null)
            {
                return (reverse == false) ? Visibility.Hidden:Visibility.Visible;
            }
            else
            {
                return (reverse == false) ? Visibility.Visible : Visibility.Hidden;
            }
        }

        public object ConvertBack(object value, Type targetType, object parameter, CultureInfo culture)
        {
            //throw new NotImplementedException();
            return null;
        }
    }
}
